<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%--
  Created by IntelliJ IDEA.
  User: 黑黑侠
  Date: 2019/11/5
  Time: 22:02
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>教师选课页面</title>
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <style type="text/css">
        *{
            margin:0;
            padding:0;
        }
        .div{
            margin-top:30px;
            width:100%;
            font-size:20px;
            text-align:center;
        }
        .title{
            width: 100%;
            height: 50px;
            line-height: 80px;
            /*text-align: center;*/
            font-size: 30px;
            font-family: kaiti;
        }
        a{
            color: #fff;
        }
    </style>
</head>
<body>

    <div style="width:705px;height: 700px; margin: 0 auto">
        <div class="title">

            <form action="find">
                <button onclick="goReturn()" class="btn btn-warning"style="font-size: 20px;">⬅</button>
                <b style="margin-left: 180px">教师选课界面</b>
                <input type="text" name="courseIdName" style="height: 40px;width: 100px;position: relative;left: 80px">
                <button class="btn btn-info" style="position: relative;left: 80px">查询</button>
            </form>
<%--            <a hidden>${teacher.tea_name}</a>--%>
<%--            <a hidden>${teacher.gettea_account()}</a>--%>
        </div>
        <div>
            <div class="div">
                <table class="table table-striped">
                    <thead style="background-color: #87CEFA;opacity: 0.9">
                    <tr>
                        <th>ID</th><th>课序号</th><th>课程名称</th><th>上课时间</th><th>学分</th><th>课时</th><th>必修/选修</th><th>课容量</th><th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <c:forEach var="data" items="${listDatas}" >
                        <tr>
                            <td>${data.id}</td>
                            <td id="no">${data.course_no}</td>
                            <td>${data.course_name}</td>
                            <td id="start" hidden>${data.course_start}</td>
                            <td id="time">${data.course_start}~${data.course_end}</td>
                            <td>${data.course_socer}</td>
                            <td>${data.course_hour}</td>
                            <td>${data.course_attribute}</td>
                            <td>${data.course_volume}</td>
                            <td><button class="btn btn-info"><a onclick="addTo(this)">添加</a></button></td>
                        </tr>
                    </c:forEach>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</body>
<script type="text/javascript">
    window.onload=function () {
        var msg = "${msg}";
        if(msg == 2){
            alert("您所查课程不存在");
        }
        if(msg == 3){
            alert("你已经添加过此课");
        }
        if(msg == 4){
            alert("时间冲突,无法加入此课程");
        }
    }

    function addTo(e) {
        var no = $(e).parent().parent().parent().children("#no").text();
        var start = $(e).parent().parent().parent().children("#start").text();
        // alert(no);
        // alert(start);
        var a =window.confirm("确定要添加此课吗?");
        if(a){
            window.location.href="addTo?teacher=${teacher.gettea_account()}&course="+no+"&time="+start;
        }
    }
    function goReturn() {
        window.history.go(-1);
    }
</script>
</html>
